﻿using IBll;
using MD5Hash;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MemberController : ControllerBase, IMemberBll
    {
        public IMemberBll Bll { get; }

        public MemberController(IMemberBll bll)
        {
            Bll = bll;
        }

        [HttpPost]
        public async Task<int> AddMember(Member member)
        {
            member.Pwd = member.Pwd.GetMD5();
            return await Bll.AddMember(member);
        }
        [HttpGet]
        public List<MemberLevel> GetMemberLevel()
        {
            return Bll.GetMemberLevel();
        }
        [HttpGet]
        public dynamic GetMember(string? name, string? levelId, DateTime? dateTime, int min, int max, int sex)
        {
            return Bll.GetMember(name, levelId, dateTime, min, max, sex);
        }
        [HttpDelete]
        public async Task<int> DelMember(int id)
        {
            return await Bll.DelMember(id);
        }
        [HttpGet]
        public Member FanTian(int id)
        {
            return Bll.FanTian(id);
        }
        [HttpPut]
        public async Task<int> UpdaMember(Member member)
        {
            return await Bll.UpdaMember(member);
        }
    }
}
